package org.jiajie.designpatterndemo.service.locator;

/**
 * 为 JNDI 查询创建 InitialContext
 *
 * @author jie
 */
public class InitialContext {

    public Object lookup(String jndiName){
        if (jndiName.equalsIgnoreCase("Service1")) {
            System.out.println("Looking up and creating a new Service1 object");
            return new Service1();
        } else if (jndiName.equalsIgnoreCase("Service2")) {
            System.out.println("Looking up and creating a new Service2 object");
            return new Service2();
        }
        return null;
    }
}
